import Utils from "@/utils/utils.js"
//查询商品列表  
export function getGoodList(pageNum, pageSize, tCommodityname, tMerchantid, deptId) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `scc/commodityinfo/MobileCommoditylist?pageNum=${pageNum}&pageSize=${pageSize}&tCommodityname=${tCommodityname}&tMerchantid=${tMerchantid}&deptId=${deptId}&reasonable=false`
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//查询商户商品列表
export function getShopGoodList(pageNum, pageSize, tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getCommoditylist?pageNum=${pageNum}&pageSize=${pageSize}&tMerchantid=${tMerchantid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}
//删除商品
export function goodDete(tCommodityid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/removeCommodityinfo/${tCommodityid}`,
			method: "DELETE",
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//查询商品详细信息
export function getGoodDetail(tCommodityid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getCommodityInfo/${tCommodityid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//新增浏览记录
export function addHistory(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/addHistory`,
			method: "POST",
			data: params,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

// 获取浏览记录
export function getHistory(memberId) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getHistoryList?tBrowseid=${memberId}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//删除浏览记录
export function removeHistory(tHistoryid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/deleteHistory/${tHistoryid}`,
			method: "DELETE",
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

// 更新浏览量
export function updatePageView(tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/updatePageView/${tMerchantid}`,
			method: "PUT",
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//购物车新增
// export function addShopping(params) {
// 	return new Promise((resolve, reject) => {
// 		Utils.baseRequest({
// 			url: `scc/shoppingcart/addShopping`,
// 			method: "POST",
// 			data: params,
// 		}).then(res => {
// 			resolve(res.data)
// 		}, err => {
// 			reject(err)
// 		})
// 	})
// }

//查询用户购物车列表 会员id
// export function getShopping(memberId) {
// 	return new Promise((resolve, reject) => {
// 		Utils.baseRequest({
// 			url: `scc/shoppingcart/getShoppingListByMemberId/${memberId}`,
// 		}).then(res => {
// 			resolve(res.data)
// 		}, err => {
// 			reject(err)
// 		})
// 	})
// }
//修改购物车商品
// export function editShopping(params) {
// 	return new Promise((resolve, reject) => {
// 		Utils.baseRequest({
// 			url: `scc/shoppingcart/editShopping`,
// 			method: "PUT",
// 			data: params,
// 		}).then(res => {
// 			resolve(res.data)
// 		}, err => {
// 			reject(err)
// 		})
// 	})
// }
//购物车删除商品
// export function removeShopping(tShoppingid) {
// 	return new Promise((resolve, reject) => {
// 		Utils.baseRequest({
// 			url: `scc/shoppingcart/removeShopping/${tShoppingid}`,
// 			method: "DELETE",
// 		}).then(res => {
// 			resolve(res.data)
// 		}, err => {
// 			reject(err)
// 		})
// 	})
// }